home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / BBS / MUBBS / E-Mail 1.5 source.cpt / E-mail / CheckEmail.c next >
Text File  |  1992-01-03  |  4KB  |  142 lines

  1. /* *********************************************************************************
  2.      
  3.       MODULE:        CheckEmail Module
  4.       
  5.      DESCRIPTION:    This CheckEmail Module is a simple module for MUBBS, the
  6.                      Multi-User Bulliten Board System Software.
  7.                      
  8.      AUTHOR:        Noam Freedman
  9.      
  10.      Copyright © 1990 by Noam Freedman. Portions are also Copyright Symantec Corp.
  11.  
  12.      This program source code and it's compiled version IS NOT IN THE
  13.      PUBLIC DOMAIN ! Please read the "COPYRIGHT NOTICE / NMF" file for details
  14.      regarding use of this program source code and it's compiled version.
  15.      
  16.      Revision History:
  17.      ============================================================
  18.      10/20/91 - Started programming
  19.      11/ 4/91 - Edited for release
  20.      ============================================================
  21.      
  22.  
  23.     ******************************************************************************** */
  24.  
  25. #define        INMAIN
  26.  
  27.  
  28. #include    "MUBBS Module.h"
  29. #include    <SetUpA4.h>
  30. #include    "Email.h"
  31.  
  32.  
  33. pascal void main (mode1,G1,P1)
  34.        int mode1;
  35.        struct GS *G1;
  36.        Ptr P1;  
  37. {
  38. Handle temph;
  39. float version = 0.5; /* what version of MUBBS you are compatable with IE: .5 and above */
  40. RememberA0(); SetUpA4(); /* This sets up the A4 register to access our globals */
  41. asm { _RecoverHandle }; asm {move.l a0,temph}; HLock(temph); /* locks our module, do this ! */
  42.  
  43. G=G1; /* This MUST be the first thing you do in main only, it sets up the struct globals */
  44. mode[u]=mode1; /* set up our mode so that you can read it anywhere */
  45.  
  46.  
  47. switch (mode[u]) { /* any un-handled modes return error from this module */
  48.     case 3:
  49.         findemail(P1); /* mode 3 because we are passing a user pointer */
  50.         G->moduleresult=0;
  51.         break;
  52.     case 98:
  53.         versionck(version); /* just return after this call, don't modify anything */
  54.         break;        
  55.     case 0:
  56.         strcpy (G->programmer,"Noam Freedman"); /* show the programmer's name up to 20 chars*/
  57.         G->moduleresult=0; /* this was also a init call if we need close call put 99 here */
  58.         break;
  59.     default:
  60.         G->moduleresult=1; /* return bad code */
  61.     };
  62.  
  63. HUnlock(temph); /* unlocks this module, do this ! */
  64. RestoreA4(); /* call this when you are all done */
  65. }
  66.  
  67.  
  68. findemail(S)
  69. struct LoadStruct *S;
  70. {
  71. struct MsgStruct MsgInfo;
  72. int a, num, numemail, count;
  73. FILE *fp_headers;
  74. long int temp;
  75. char tempc[maxnamelength];
  76.  
  77. if (!G->online[u]) { num = 2;goto byebye; } /* do this check so we can log out if hang up */
  78.  
  79.  
  80. if ( (fp_headers = fopen(":msgs:email.headers","r")) == NULL )
  81.     {
  82.     send("]Can't open the file: %s]]",":msgs:email.headers");
  83.     num = 3;
  84.     }
  85. else
  86.     {
  87.     count=0;
  88.     a = 0;
  89.     num = 0;
  90.     numemail=0;
  91.     while (a == 0)
  92.         {    
  93.         temp = ftell(fp_headers);
  94.         fread( MsgInfo.FromUser, sizeof(MsgInfo),1,fp_headers);    
  95.         if (feof(fp_headers) == 0)
  96.             {
  97.             if ( numemail < MAXEMAIL )
  98.                 {
  99.                 strtoupper(MsgInfo.ToUser);
  100.                 strcpy(tempc,G->username[u]); /* check the name uppercased! */
  101.                 strtoupper(tempc);
  102.                 if (strcmp(MsgInfo.ToUser,tempc) == 0)
  103.                 if (MsgInfo.status != DELETED )
  104.                     {
  105.                     numemail = numemail+1;
  106.                     S->i_headers[numemail] = temp;
  107.                     sscanf(MsgInfo.FromUser,"%35[ -~]",S->FromUser[numemail]); /* correct the length */
  108.                     sscanf(MsgInfo.title,"%70[ -~]",S->title[numemail]); /* correct the length */
  109.                     S->status[numemail] = MsgInfo.status;
  110.                     sscanf(MsgInfo.NetAddress,"%20[ -~]",S->NetAddress[numemail]); /* correct the length */
  111.                     S->offset[numemail] = MsgInfo.offset;
  112.                     S->length[numemail] = MsgInfo.length;
  113.                     sscanf(MsgInfo.DateSent,"%25[ -~]",S->DateSent[numemail]); /* correct the length */
  114.                     }
  115.                 }
  116.             else
  117.                 {
  118.                 a = 1;    /* More than MAXEMAIL msgs */
  119.                 num = 20;
  120.                 }
  121.             }
  122.         else
  123.             {
  124.             a = 1; /* ran into EOF */
  125.             num = 0;
  126.             }
  127.         if ((++count % 10) == 0) {sendnc (".");} /* show dots */
  128.         }
  129.     fclose(fp_headers); /* close that file ! */
  130.     }
  131. if(numemail <1 && num == 0)
  132.     {
  133.     num = 21;  /* No email found */
  134.     }
  135.  
  136. S->numemail = numemail;
  137. byebye:
  138. S->result = num;
  139. return;
  140. }
  141.  
  142.